import { PropType } from "vue";

/**
 * 用户传入的source必须要有nodeKey， name
*/
type nodeKey = string | number; // 唯一索引

interface TreeNodeOptions {
  nodeKey: nodeKey;
  name: string;
  level?: number; // 控制缩进
  loading?: boolean;  // 图标
  disabled?: boolean; // 禁用
  expanded?: boolean; // 展开
  selected?: boolean; // 选中
  checked?: boolean;  // 勾选
  hasChildren?: boolean; // 为子节点存在
  children?: TreeNodeOptions[]; // 子节点
  parentKey?: nodeKey | null; // 
};
interface TreeInstance {
  getSelectedNode: () => RequiredTreeNodeOptions | undefined;
  getCheckedNodes: () => RequiredTreeNodeOptions[];
  getHalfCheckedNodes: () => RequiredTreeNodeOptions[];
}

type RequiredTreeNodeOptions = Required<TreeNodeOptions>; // 为子类必选择

type renderFunc = (node: RequiredTreeNodeOptions) => JSX.Element;

interface TreeNodeInstance {
  node: RequiredTreeNodeOptions;
  halfChecked: () => boolean;
}
export { nodeKey, TreeNodeOptions, TreeInstance, RequiredTreeNodeOptions, renderFunc, TreeNodeInstance }